/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.router.test.base;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.RandomUtil;
import com.google.common.collect.Lists;
import info.peigen.hotpot.business.router.core.repository.entity.RouterChannelEntity;
import info.peigen.hotpot.business.router.core.repository.service.RouterChannelRepository;
import info.peigen.hotpot.business.router.core.repository.service.RouterTransLogRepository;
import info.peigen.hotpot.business.router.core.repository.service.RouterWithdrawRepository;
import info.peigen.hotpot.business.router.facade.enums.ChannelBusinessType;
import info.peigen.hotpot.business.router.facade.enums.ChannelCode;
import info.peigen.hotpot.business.router.facade.enums.ChannelCurrencyType;
import info.peigen.hotpot.business.router.facade.order.payee.QueryReceiptChannelOrder;
import info.peigen.hotpot.common.core.util.IdUtil;
import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
import org.noear.solon.annotation.Inject;

import java.util.List;

import static info.peigen.hotpot.business.router.facade.enums.RouterAction.Query_All_Receipt;
import static info.peigen.hotpot.common.core.enums.Currency.*;

/**
 * <b>(RouterRepositoryTestBase)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/4/25
 */
@FieldDefaults(level = AccessLevel.PROTECTED)
public class RouterRepositoryTestBase extends RouterTestBase {
    @Inject
    RouterChannelRepository  routerChannelRepository;
    @Inject
    RouterTransLogRepository routerTransLogRepository;
    @Inject
    RouterWithdrawRepository routerWithdrawRepository;

    protected QueryReceiptChannelOrder genQueryReceiptChannelOrder() {
        return QueryReceiptChannelOrder.builder()
                .bizOrderNo(RandomUtil.randomString(20))
                .productCode(Query_All_Receipt.code())
                .build();
    }

    protected List<RouterChannelEntity> defaultReceiptChannel() {
        RouterChannelEntity entity = RouterChannelEntity.builder()
                .channelId(IdUtil.id())
                .channelCode(ChannelCode.Weixin)
                .channelBusinessType(ChannelBusinessType.Receipt)
                .channelCurrencyType(ChannelCurrencyType.Multi)
                .currency(USD).build();
        return Lists.newArrayList(entity,
                BeanUtil.copyProperties(entity, RouterChannelEntity.class).setChannelId(IdUtil.nextId(entity.getChannelId(), 1)).setCurrency(JPY),
                BeanUtil.copyProperties(entity, RouterChannelEntity.class).setChannelId(IdUtil.nextId(entity.getChannelId(), 2)).setCurrency(HKD),
                BeanUtil.copyProperties(entity, RouterChannelEntity.class).setChannelId(IdUtil.nextId(entity.getChannelId(), 3)).setCurrency(CNY),
                BeanUtil.copyProperties(entity, RouterChannelEntity.class).setChannelId(IdUtil.nextId(entity.getChannelId(), 4)).setCurrency(GBP),
                BeanUtil.copyProperties(entity, RouterChannelEntity.class).setChannelId(IdUtil.nextId(entity.getChannelId(), 5)).setCurrency(EUR),
                BeanUtil.copyProperties(entity, RouterChannelEntity.class).setChannelId(IdUtil.nextId(entity.getChannelId(), 6)).setCurrency(SGD));
    }
}
